/**
 * @author Nicolas Zimerman (zimerman@usi.ch)
 * @author Isabella Nake (isabella.nake@usi.ch)
 * @author Nicolas Lusa (lusan@usi.ch)
 * @author Nicolas Latorre (nicolas.latorre@usi.ch)
 */
package ch.usi.inf.pf2;

import ch.usi.inf.pf2.circuit.AndGate;
import ch.usi.inf.pf2.circuit.Circuit;
import ch.usi.inf.pf2.circuit.Gate;
import ch.usi.inf.pf2.circuit.Input;
import ch.usi.inf.pf2.circuit.InputPin;
import ch.usi.inf.pf2.circuit.InputPinForGate;
import ch.usi.inf.pf2.circuit.InputPinForOutput;
import ch.usi.inf.pf2.circuit.NotGate;
import ch.usi.inf.pf2.circuit.Output;
import ch.usi.inf.pf2.circuit.OutputPin;
import ch.usi.inf.pf2.circuit.Value;
import ch.usi.inf.pf2.circuit.Wire;
import ch.usi.inf.pf2.time.Event;
import ch.usi.inf.pf2.time.Schedule;
import ch.usi.inf.pf2.time.SetValueOfInputEvent;
import ch.usi.inf.pf2.file.interaction.InstructionReader;
import ch.usi.inf.pf2.file.interaction.Lexer;
import ch.usi.inf.pf2.file.interaction.Parser;
import ch.usi.inf.pf2.file.interaction.Token;
import ch.usi.inf.pf2.gui.CircuitFrame;
import ch.usi.inf.pf2.gui.Model;

import java.awt.EventQueue;


public final class LogicSim {
	
	public static void main(final String[] args) {
		
		// create the model
        final Model model = new Model();
        
        // create the GUI (in the GUI thread)
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                final CircuitFrame frame = new CircuitFrame(model);
                frame.setVisible(true);
            }
        });
	}
        
    public LogicSim(final Model model) {
        // create the GUI (in the GUI thread)
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                final CircuitFrame frame = new CircuitFrame(model);
                frame.setVisible(true);
            }
        });
	}
    
		//UNCOMMENT THIS PART TO WRITE AND READ FROM A FILE.
		/*
		InstructionWriter writer = new InstructionWriter();
		writer.chooseLocationToSaveTheFile();
		writer.putInstruction();
		writer.writeInstruction(writer.getLocation());
		
		*/
//		Parser parser = new Parser("/Users/usi/Desktop/nuovo.xml");
//		parser.parse();
		
		
//		ArrayList<Token> tokens = lexer.getTokens();
//		for(Token t : tokens) {
//			System.out.println(t.getType());
//		}
		
		
//		Parser parser = new Parser("/Users/usi/Desktop/nuovo.xml");
//		ArrayList<Token> token = parser.getTokens();
//		for(Token t : token) {
//			System.out.println("hey");
//			System.out.println(t.getType());
//		}
//		ArrayList<Node> c = parser.getCircuit();
//		for(Node n : c) {
//			System.out.println(n.toString());
//		}
		
//		parser.reverseToken();
//		ArrayList<Node> nodes = parser.parse();
//		ArrayList<Node> circuit = new ArrayList<Node>();
//		for(int i = nodes.size() -1; i >= 0; i--) {
//			circuit.add(nodes.get(i));
//		}
//		for(Node n : circuit) {
//			System.out.println(n.toString());
//		}
		
		
}


